
Volvo.CareTrack.NetworkOperationClass = function() {};

proto = Volvo.CareTrack.NetworkOperationClass.prototype;

proto.request = function(params) {
	
	var url = Volvo.CareTrack.Global.settings.jsonCallHost + params.urlPath;

	var ajaxObj={ 
		url: url, 
		data: params.data,
		beforeSend: function(jqXHR, settings) {
			console.log('Network request made: ' + settings.url);
		},
		error: function(jqXHR, textStatus, errorThrown) {
			params.error();
		},
		success: function(data) {
			for (var key in data) break;
			if (key==='error') {
				var error = data[key];
				params.error(error);
				return;
			}
			params.success(data);
		}
	}
	
	$.ajax(ajaxObj);
};

Volvo.CareTrack.NetworkOperation = new Volvo.CareTrack.NetworkOperationClass();
